package reflect;

/**
 * JDK5之后推出了一个特性:变长参数
 */
public class ArgDemo {
    public static void main(String[] args) {
        doSome("one");
        doSome("1","2");
        doSome("1","2","3","2","3","2","3","2","3","2","3","2","3","2","3","2","3","2","3","2","3","2","3","2","3","2","3","2","3","2","3","2","3");
        /*
            doSome("one",new String[]{});
            doSome("1",new String[]{"2"});
            doSome("1",new String[]{"2","3","2","3","2","3","2","3","2","3","2","3","2","3","2","3","2","3","2","3","2","3","2","3","2","3","2","3","2","3","2","3"});
        */
    }
    /*
        变长参数是编译器认可，而非虚拟机，编译器会将变长参数改为对应的数组类型
        注意:
            1：变长参数类型后面必须跟"..."。
            2：一个方法中只能是最后一个参数为变长参数
     */
    public static void doSome(String d,String... s){
//    public static void doSome(String d,String[] s){
        System.out.println(s.length);
        for (String e : s) {
            System.out.println(e);
        }
    }
}
